﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SnackXpress.Observer.Observer;
using SnackXpress.Observer.Subject;
using SnackXpress.Producten;
using SnackXpress.abstract_factory;
using SnackXpress.Ingredienten;

namespace SnackXpress.Client
{
    public class McDonaldWinkel : SnackXpress, IObserver
    {
        private Snack snack = null;
        private double discount = 1.00;

        public McDonaldWinkel(DiscountSubject discount)
        {
            discount.RegisterObserver(this);
        }       

        protected override Snack CreateSnack(string type)
        {
            ISnackXpressFactory factory = new BurgerKingFactory();

            if (type.Equals("Kleine hamburger"))
            {
                snack = new SmallBurger();
                snack.Name = "Kleine hamburger";
                snack.snack = factory.CreateSnack(new Hamburger());
                snack.cheese = factory.CreateCheese();
                snack.vegetable = factory.CreateVegetables();
                snack.sauce = factory.CreateSauces();
                snack = new BrownBread(snack);
            }
            else if (type.Equals("Medium hamburger"))
            {
                snack = new MediumBurger();
                snack.Name = "Medium hamburger";
                snack.snack = factory.CreateSnack(new Hamburger());
                snack.cheese = factory.CreateCheese();
                snack.vegetable = factory.CreateVegetables();
                snack.sauce = factory.CreateSauces();
                snack = new BrownBread(snack);
            }
            else if (type.Equals("Grote hamburger"))
            {
                snack = new BigBurger();
                snack.Name = "Big burger";
                snack.snack = factory.CreateSnack(new Hamburger());
                snack.cheese = factory.CreateCheese();
                snack.vegetable = factory.CreateVegetables();
                snack.sauce = factory.CreateSauces();
                snack = new BrownBread(snack);
                snack = new BrownBread(snack);
            }
            else if (type.Equals("Broodje Frikandel"))
            {
                snack = new BroodjeFrikandel();
                snack.Name = "Broodje Frikandel";
                snack.snack = factory.CreateSnack(new Frikandel());
                snack.cheese = factory.CreateCheese();
                snack.vegetable = factory.CreateVegetables();
                snack.sauce = factory.CreateSauces();
                snack = new BrownBread(snack);
            }
            else if (type.Equals("Frikandel"))
            {
                snack = new FrikandelLos();
                snack.Name = "Frikandel";
                snack.snack = factory.CreateSnack(new Frikandel());
                snack.cheese = factory.CreateCheese();
                snack.sauce = factory.CreateSauces();
            }
            return snack;
        }

        public double getPrijs()
        {
            return ((double)(snack.GetCost() * this.discount));
        }

        public void Update(int discount)
        {
            this.discount = (double)(100 - discount) / 100;
        }

        public override string Name { get; set; }
    }
}